#ifndef PACK_H
#define PACK_H
#include <cstring>
#include <QStringList>
#include <QTcpSocket>
class myClient;

enum Type{
    TYPE_CAMERA_TRANSLATING,
    TYPE_CAMERA_TRANSLATE_END,
    TYPE_FACE
};

enum Err{
    NO_ERR,
    HAVE_ERR,
    TYPE_FACE_SAVE_OK,
    TYPE_FACE_EXISTS,
    TYPE_FACE_LOGIN_OK
};

class Pack
{
private:
    int pack_size = 12;
    Type type = (Type)0;
    Err err;
    char buf[4096] = {0};
    int count = 0;
public:
    Pack();
    void setType(Type type);
    void setErr(Err err);
    Type getType();
    Err getErr();

    void append(const QString& str);
    void append(const char* data,int size);
    QStringList analysis();

    Pack& operator<<(const QString& data);
    void operator>>(QTcpSocket* client);
    void operator>>(myClient* client);

    QByteArray getByteArray(int size);
};

#endif // PACK_H
